package com.yuanfengerp.retailback.controller;

import com.yuanfengerp.publicUtil.Result;
import com.yuanfengerp.retailback.model.RetailBackBoundOrder;
import com.yuanfengerp.retailback.servicer.IRetailBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/backOrder")
public class RetailBackController {

    @Autowired
    private IRetailBackService retailBackService;

    /**
     *  新增退货单
     * @param retailBackBoundOrder
     * @return
     */
    @PostMapping("/insert")
    public Result<RetailBackBoundOrder> insertBackOrder(@RequestBody RetailBackBoundOrder retailBackBoundOrder) {
        return retailBackService.insertBackOrder(retailBackBoundOrder);
    }

    /**
     *
     * @param retailReturnOrderNumbers
     * @return
     */
    @PostMapping("/update/agree")
    public Result<RetailBackBoundOrder> updateBackOrderAgree(@RequestBody String[] retailReturnOrderNumbers) {
        return retailBackService.updateBackOrderAgree(retailReturnOrderNumbers);
    }

    @PostMapping("/update/refuse")
    public Result<RetailBackBoundOrder> updateBackOrderRefuse(@RequestBody String[] retailReturnOrderNumbers) {
        return retailBackService.updateBackOrderRefuse(retailReturnOrderNumbers);
    }

    @GetMapping("/selectAll")
    public Result<List<String>> selectAllOutOrder(@RequestParam Map<String, Object> condition) {
        return retailBackService.selectAllOutOrder(condition);
    }

    @GetMapping("/select/{orderNumber}")
    public Result<RetailBackBoundOrder> selectBackOrder(@PathVariable String orderNumber) {
        return retailBackService.selectBackOrder(orderNumber);
    }
}